# import time
#
# import lxml
# from lxml import etree
# from selenium.webdriver import ActionChains
# from spidertools import selenium_init
#
# d = selenium_init.get_browser()
# d.get("https://www.qcc.com/")
# d.maximize_window()
# time.sleep(1)
#
# d.find_element_by_partial_link_text('登录 | 注册').click()
# time.sleep(1)
# d.find_element_by_id("normalLogin").click()
# # d.find_element_by_id("nameNormal").send_keys("18691568935")
# d.find_element_by_id("nameNormal").send_keys("17366203236")
# time.sleep(1.2)
# # d.find_element_by_id("pwdNormal").send_keys("Hh11220033")
# d.find_element_by_id("pwdNormal").send_keys("q653636006q")
# time.sleep(0.6)
#
#
# def get_track(distance, t):
#     track = []
#     current = 0
#     mid = distance * t / (t + 1)
#     v = 0
#     while current < distance:
#         if current < mid:
#             a = 3
#         else:
#             a = -1
#         v0 = v
#         v = v0 + a * t
#         move = v0 * t + 1 / 2 * a * t * t
#         current += move
#         track.append(round(move))
#     return track
# # # deal with 滑动验证码
# # try:
# #     g = d.find_element_by_id('nc_2_n1z')
# #     ActionChains(d).click_and_hold(g).perform()
# #     l = get_track(308, 0.5)
# #     l.append(-6)
# #     l.append(6)
# #     for x in l:
# #         ActionChains(d).move_by_offset(xoffset=x, yoffset=0).perform()
# #     ActionChains(d).release().perform()
# #     time.sleep(4)
# # except Exception as e:
# #     print(e)
#
# time.sleep(3)
# d.find_element_by_xpath('//form[@id="user_login_normal"]/button[@type="submit"]').click()
#
# time.sleep(3)
# d.find_element_by_xpath('//div[@class="input-group"]/input[@id="searchkey"]').send_keys('钢构')
# print(d.find_element_by_xpath('//div[@class="input-group"]/input[1]').get_attribute('placeholder'))
# d.find_element_by_xpath('//input[@class="index-searchbtn"]').click()
#
# time.sleep(4)
#
#
# def handle_parse(page_source):
#     html = etree.HTML(page_source)
#     print(etree.tostring(html).decode('utf-8'))
#     print(etree.tostring(html).decode())
#     list_div = []
#     div_all = html.xpath('//div[@class="proinv-wrap"]')
#     for div  in div_all:
#         # dict_one = dict()
#         print(div.xpath('./text()'))
#         div1 = div.xpath('./a/text()')
#         print(div1)
#         # s1 = etree.tostring(div1).decode('utf-8')
#         # s1 = etree.tostring(div1).decode('utf-8')
#         print(div.xpath('./a/@href'))
#         print(div.xpath('./a/@onclick'))
#
#
#     print("==================")
#     objs = html.xpath('//tbody[@id="search-result"]/tr/td')
#     for obj in objs:
#         print("1",obj.xpath('./a/@href'))
#         print("2",obj.xpath('./a/@onclick'))
#         print("3",obj.xpath('./p/text()'))
#         print("4",obj.xpath('./p[1]/a/text()'))
#         print("5",obj.xpath('./p[1]/a/span[1]/text()'))
#         print("6",obj.xpath('./p[1]/a/span[2]/text()'))
#         print("7",obj.xpath('./p[2]/span[2]/text()'))
#
#
#
#
#
#     #     dict_one["job_name"] = i.xpath("./p/span/a/@title")[0]  # 结果是一个列表，只有一个元素，所以要取出来
#     #     dict_one['address'] = i.xpath("./span[@class='t3']/text()")[0]
#     #     dict_one['company'] = i.xpath("./span/a/@title")[0]
#     #     try:
#     #         dict_one['salary'] = i.xpath("./span[@class='t4']/text()")[0]
#     #     except IndexError:  # 可能有的未标明薪资，这里要处理一下
#     #         dict_one['salary'] = '无数据'
#     #     dict_one['date'] = i.xpath("./span[@class='t5']/text()")[0]
#     #     list_div.append(dict_one)  # 添加到列表中
#     # print(list_div)
#     # return list_div  # 这里省略了存放入mongodb数据库
# time.sleep(2)
# handle_parse(d.page_source)
#
# d.find_element_by_id('ajaxpage').click()
#
# time.sleep(10)
#
# d.quit()
#
